<template>
  <!-- section 语义标签 -->
  <section class="app-main" style="min-height: 100%">
    <!-- transition 过度动画标签 -->
    <transition name="fade" mode="out-in">
      <keep-alive :include="cachedViews">
        <!-- 组件缓存 -->
        <!-- 包裹动态组件时，会缓存不活动的组件实例,主要用于保留组件状态或避免重新渲染 -->
        <!-- 占位符, 侧导航栏和tags标签跳转，在此展示 -->
        <!-- include 字符串或正则表达式，只有名称匹配的组件会被缓存 -->
        <router-view></router-view>
      </keep-alive>
    </transition>
  </section>
</template>

<script>
export default {
  name: 'layoutAppMain',
  computed: {
    cachedViews () {
      return this.$store.state.tagsView.cachedViews // 返回当前需要缓存组件的名字
    }
    // key() {
    //   return this.$route.name !== undefined ? this.$route.name + +new Date() : this.$route + +new Date()
    // }
  }
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.app-main{
  position: relative;
  top: 75px;
  // z-index: 0;
}
</style>
